package com.sskj.aikeeper;

import com.lzy.okgo.model.Response;
import com.sskj.aikeeper.bean.CetificationBean;
import com.sskj.aikeeper.bean.NoticeListBean;
import com.sskj.aikeeper.presenter.BasePresenter;
import com.sskj.common.base.HttpData;
import com.sskj.lib.BaseHttpConfig;
import com.sskj.lib.bean.PageBean;
import com.sskj.lib.http.JsonCallBack;

public class MainPresenter extends BasePresenter<MainActivity> {
    public void getCertificationStatus() {
        httpService.getCertificationStatus()
                .tag(this)
                .execute(new JsonCallBack<HttpData<CetificationBean>>() {
                    @Override
                    public void onSuccess(Response<HttpData<CetificationBean>> response) {
                        if (response.body().status == BaseHttpConfig.OK) {
                            mView.getStatusOK(response.body().getData());
                        }
                    }
                });
    }

    public void getNotification(long time, int page, int size) {
        httpService.getNoticeList(time, page, size)
                .tag(this)
                .execute(new JsonCallBack<HttpData<PageBean<NoticeListBean>>>() {
                    @Override
                    public void onSuccess(Response<HttpData<PageBean<NoticeListBean>>> response) {
                        if (response.body().status == BaseHttpConfig.OK) {
                            if (response.body().getData() == null) {
                                return;
                            }
                            if (response.body().getData().getList().size() == 0) {
                                return;
                            }
                            mView.sendNotification(response.body().getData().getList().get(0));
                        }
                    }
                });
    }
}
